home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / The Hacks! / BrickPoint / Brickout.h < prev    next >
Text File  |  1998-06-21  |  5KB  |  176 lines

  1. //******************************************************************************
  2. //******************************************************************************
  3. /*
  4.     File:        Brickout.h
  5.  
  6.     Contains:    Header for a sample dcmd which plays brickout.
  7.  
  8.     Written by:    Andy Bachorski and Nat McCully
  9.  
  10.     Copyright:    © 1998 by Apple Computer, Inc., All Rights Reserved.
  11.  
  12.     Change History (most recent first):
  13.     
  14.         <1> 98-6-19        Written for the MacHack 98 Hack Contest.
  15.  
  16.     The following MPW commands will build the dcmd and copy it to the "Debugger Prefs" file
  17.     in the System folder. The dcmd's name in MacsBug will be the name of the file built by
  18.     the Linker.
  19.  
  20.     set MacsBugLibs "Tools:OtherSDKs:Building dcmds:MacsBug 6.5.4a3:MacsBug 6.5.4a3:Building dcmds:dcmd Libraries:"
  21.     SC BrickOut.c  -i "Tools:OtherSDKs:Building dcmds:MacsBug 6.5.4a3:MacsBug 6.5.4a3:Building dcmds:dcmd Includes:"
  22.     Link -o BrickOut -sg Main=STDCLIB,STDIO,SANELIB BrickOut.o ∂                                                                ∂
  23.         "{MacsBugLibs}dcmdGlue.a.o"
  24.     BuildDcmd BrickOut 195 -format3
  25.     Echo 'include "BrickOut";'    |    Rez -a -o "{SystemFolder}Debugger Prefs"
  26.  
  27. */
  28.  
  29.  
  30. //******************************************************************************
  31.  
  32. #ifndef _MacBrickOut_
  33. #define _MacBrickOut_
  34.  
  35. #ifndef __MEMORY__
  36. #include <Memory.h>
  37. #endif
  38.  
  39. #ifndef __TYPES__
  40. #include <Types.h>
  41. #endif
  42.  
  43. #ifndef __QUICKDRAW__
  44. #include <Quickdraw.h>
  45. #endif
  46.  
  47. #ifndef __STRING__
  48. #include <string.h>
  49. #endif
  50.  
  51. #ifndef __DCMD__
  52. #include "dcmd.h"
  53. #endif
  54.  
  55. //******************************************************************************
  56.  
  57. #define kScreenLines    42
  58. #define    MaxSpeed        4
  59.  
  60. #define    BricksH            numBricksX
  61. #define    BricksV            numBricksY
  62.  
  63. #define    WidthCalc        brickWidth
  64. #define    HeightCalc        brickHeight
  65.  
  66. #define kHit            1
  67. #define    kSafe            0
  68.  
  69. #define    KeyMapLoMem     ((unsigned char *)0x174)
  70. #define KeyIsDown(key)    (( KeyMapLoMem[ key >> 3 ] >> ( key & 7)) &1)
  71.  
  72. #define    aKey            0x00
  73. #define    sKey            0x01
  74. #define    fourKey            0x56
  75. #define    sixKey            0x58
  76.  
  77. #define kSplashColorBlack    0x15
  78. #define kSplashColorBlue    0x02
  79. #define kSplashColorLtBlue    0x03
  80. #define kSplashColorGreen    0x04
  81. #define kSplashColorPurple    0x01
  82. #define kSplashColorRed        0x06
  83. #define kSplashColorYellow    0x05
  84.  
  85. //******************************************************************************
  86.  
  87. enum {
  88.     numRows            = 0x01a8,
  89.     topBorder        = 8,
  90.     bottomBorder    = 8,
  91.     sideBorder        = 4,
  92.     leftEdge        = 74,
  93.     brickWidth        = 56,                // byte * 8 = 48 pixels
  94.     halfBrickWidth    = brickWidth / 2,
  95.     brickHeight        = 12,                // 1 row = 1 pixel * 12 = 12 pixels
  96.     halfBrickHeight    = brickHeight / 2,
  97.     numBricksX        = 10,
  98.     numBricksY        = 6,
  99.     kWhite            = 0x00,
  100.     kBlack            = 0x01,
  101.     kRed            = 0x02,
  102.     ballSize        = brickHeight,
  103.     halfBallSize    = ballSize / 2,
  104.     paddleWidth        = brickWidth,
  105.     halfPaddleWidth    = paddleWidth / 2,
  106.     paddleHeight    = brickHeight,
  107.     halfPaddleHeight= brickHeight / 2,
  108.     paddleMoveAmt    = 2
  109. };
  110.  
  111. //******************************************************************************
  112.  
  113. extern long            gRunning;
  114. extern long            gFellOff;
  115.  
  116. extern UInt32        gScreenBase;
  117. extern UInt32        gScreenRowBytes;
  118. extern UInt32        gScreenEnd;
  119.  
  120. extern UInt32        gDrawBoundsTop;
  121. extern UInt32        gDrawBoundsBottom;
  122. extern UInt32        gDrawWidth;
  123.  
  124. extern UInt32        gBrickLeft;
  125. extern UInt32        gBrickRight;
  126.  
  127. extern UInt32        gBallStartX;
  128. extern UInt32        gBallStartY;
  129.  
  130. extern Rect            ballRect;
  131. extern Rect            oldBallRect;
  132.  
  133. extern UInt32        gPaddleStartX;
  134. extern UInt32        gPaddleStartY;
  135.  
  136. extern Rect            paddleRect;
  137. extern Rect            oldPaddleRect;
  138.  
  139. extern Point        speed;
  140.  
  141. extern char         blackBallx[];
  142.                     
  143. extern char         blackBall[];
  144.                 
  145. extern char         whiteBall[];
  146.  
  147. extern short        BrickState[BricksH][BricksV];
  148. extern Rect            Bricks[BricksH][BricksV];
  149.  
  150. extern Rect            gSplashRect;
  151. extern char            gSplashBits[];
  152. extern Point        gSplashDimensions;
  153.  
  154.  
  155. //******************************************************************************
  156.  
  157. extern pascal void CommandEntry( dcmdBlock* paramPtr );
  158. extern void DoBrickOut( void );
  159. extern long PauseWithPolling( void );
  160. extern void InitGlobals( void );
  161. extern void InitBallStart( void );
  162. extern void DrawBorder( void );
  163. extern void DrawBricks( void );
  164. extern void DrawBrick( short xLoc, short yLoc, Rect *rect );
  165. extern void FadeToBlack( void );
  166. extern void CheckCollide( void );
  167. extern char * XYtoAddress( long xLoc, long yLoc );
  168. extern void DrawBall( Rect *ballRectPtr, char * ballBits );
  169. extern void UpdateBall( void );
  170. extern void DrawPaddle( Rect *paddleRectPtr );
  171. extern void UpdatePaddles( void );
  172. extern void DrawSplashScreen( Rect *splashRectPtr, char * splashBits, Point * dimensions );
  173.  
  174. //******************************************************************************
  175. //******************************************************************************
  176. #endif // _MacBrickOut_